home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / txtsvc / nsITextServicesDocument.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  10KB  |  281 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsITextServicesDocument_h__
  39. #define nsITextServicesDocument_h__
  40.  
  41. #include "nsISupports.h"
  42.  
  43. class nsIDOMDocument;
  44. class nsIDOMRange;
  45. class nsIPresShell;
  46. class nsIEditor;
  47. class nsString;
  48. class nsITextServicesFilter;
  49.  
  50. /*
  51. TextServicesDocument interface to outside world
  52. */
  53.  
  54. #define NS_ITEXTSERVICESDOCUMENT_IID            \
  55. { /* 019718E1-CDB5-11d2-8D3C-000000000000 */    \
  56. 0x019718e1, 0xcdb5, 0x11d2,                     \
  57. { 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
  58.  
  59.  
  60. /**
  61.  * The nsITextServicesDocument presents the document in as a
  62.  * bunch of flattened text blocks. Each text block can be retrieved
  63.  * as an nsString (array of characters).
  64.  */
  65. class nsITextServicesDocument  : public nsISupports{
  66. public:
  67.  
  68.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXTSERVICESDOCUMENT_IID)
  69.  
  70.   typedef enum { eDSNormal=0, eDSUndlerline } TSDDisplayStyle;
  71.  
  72.   typedef enum { eBlockNotFound=0, // There is no text block (TB) in or before the selection (S).
  73.                  eBlockOutside,    // No TB in S, but found one before/after S.
  74.                  eBlockInside,     // S extends beyond the start and end of TB.
  75.                  eBlockContains,   // TB contains entire S.
  76.                  eBlockPartial     // S begins or ends in TB but extends outside of TB.
  77.   } TSDBlockSelectionStatus;
  78.  
  79.   /**
  80.    * Initializes the text services document to use a particular
  81.    * DOM document.
  82.    * @param aDOMDocument is the document to use. It is AddRef'd
  83.    * by this method.
  84.    * @param aPresShell is the presentation shell to use when
  85.    * setting the selection. It is AddRef'd by this method.
  86.    */
  87.   NS_IMETHOD InitWithDocument(nsIDOMDocument *aDOMDocument, nsIPresShell *aPresShell) = 0;
  88.  
  89.   /**
  90.    * Get the DOM document for the document in use.
  91.    * @return aDocument the dom document [OUT]
  92.    */
  93.   NS_IMETHOD GetDocument(nsIDOMDocument **aDocument) = 0;
  94.  
  95.   /**
  96.    * Initializes the text services document to use a particular
  97.    * editor. The text services document will use the DOM document
  98.    * and presentation shell used by the editor.
  99.    * @param aEditor is the editor to use. The editor is AddRef'd
  100.    * by this method.
  101.    */
  102.   NS_IMETHOD InitWithEditor(nsIEditor *aEditor) = 0;
  103.  
  104.   /**
  105.    * Sets the range/extent over which the text services document
  106.    * will iterate. Note that InitWithDocument() or InitWithEditor()
  107.    * should have been called prior to calling this method. If this
  108.    * method is never called, the text services defaults to iterating
  109.    * over the entire document.
  110.    *
  111.    * @param aDOMRange is the range to use. aDOMRange must point to a
  112.    * valid range object.
  113.    */
  114.   NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) = 0;
  115.  
  116.   /**
  117.    * Gets the range that the text services document
  118.    * is currently iterating over. If SetExtent() was never
  119.    * called, this method will return a range that spans the
  120.    * entire body of the document.
  121.    *
  122.    * @param aDOMRange will contain an AddRef'd pointer to the range.
  123.    */
  124.   NS_IMETHOD GetExtent(nsIDOMRange** aDOMRange) = 0;
  125.  
  126.   /**
  127.    * Expands the end points of the range so that it spans complete words.
  128.    * This call does not change any internal state of the text services document.
  129.    *
  130.    * @param aDOMRange the range to be expanded/adjusted.
  131.    */
  132.   NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) = 0;
  133.  
  134.   /**
  135.    * Sets the filter to be used while iterating over content.
  136.    * @param aFilter filter to be used while iterating over content.
  137.    */
  138.   NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) = 0;
  139.  
  140.   /**
  141.    * Returns true if the document can be modified with calls
  142.    * to DeleteSelection() and InsertText().
  143.    * @param aCanEdit is true if the document can be modified,
  144.    * false if it can't.
  145.    */
  146.   NS_IMETHOD CanEdit(PRBool *aCanEdit) = 0;
  147.  
  148.   /**
  149.    * Returns the text in the current text block.
  150.    * @param aStr will contain the text.
  151.    */
  152.  
  153.   NS_IMETHOD GetCurrentTextBlock(nsString *aStr) = 0;
  154.  
  155.   /**
  156.    * Tells the document to point to the first text block
  157.    * in the document. This method does not adjust the current
  158.    * cursor position or selection.
  159.    */
  160.  
  161.   NS_IMETHOD FirstBlock() = 0;
  162.  
  163.   /**
  164.    * Tells the document to point to the last text block in the
  165.    * document. This method does not adjust the current cursor
  166.    * position or selection.
  167.    */
  168.  
  169.   NS_IMETHOD LastBlock() = 0;
  170.  
  171.   /**
  172.    * Tells the document to point to the first text block that
  173.    * contains the current selection or caret.
  174.    * @param aSelectionStatus will contain the text block selection status
  175.    * @param aSelectionOffset will contain the offset into the
  176.    * string returned by GetCurrentTextBlock() where the selection
  177.    * begins.
  178.    * @param aLength will contain the number of characters that are
  179.    * selected in the string.
  180.    */
  181.  
  182.   NS_IMETHOD FirstSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, PRInt32 *aSelectionOffset, PRInt32 *aSelectionLength) = 0;
  183.  
  184.   /**
  185.    * Tells the document to point to the last text block that
  186.    * contains the current selection or caret.
  187.    * @param aSelectionStatus will contain the text block selection status
  188.    * @param aSelectionOffset will contain the offset into the
  189.    * string returned by GetCurrentTextBlock() where the selection
  190.    * begins.
  191.    * @param aLength will contain the number of characters that are
  192.    * selected in the string.
  193.    */
  194.  
  195.   NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, PRInt32 *aSelectionOffset, PRInt32 *aSelectionLength) = 0;
  196.  
  197.   /**
  198.    * Tells the document to point to the text block before
  199.    * the current one. This method will return NS_OK, even
  200.    * if there is no previous block. Callers should call IsDone()
  201.    * to check if we have gone beyond the first text block in
  202.    * the document.
  203.    */
  204.  
  205.   NS_IMETHOD PrevBlock() = 0;
  206.  
  207.   /**
  208.    * Tells the document to point to the text block after
  209.    * the current one. This method will return NS_OK, even
  210.    * if there is no next block. Callers should call IsDone()
  211.    * to check if we have gone beyond the last text block
  212.    * in the document.
  213.    */
  214.  
  215.   NS_IMETHOD NextBlock() = 0;
  216.  
  217.   /**
  218.    * IsDone() will always set aIsDone == PR_FALSE unless
  219.    * the document contains no text, PrevBlock() was called
  220.    * while the document was already pointing to the first
  221.    * text block in the document, or NextBlock() was called
  222.    * while the document was already pointing to the last
  223.    * text block in the document.
  224.    * @param aIsDone will contain the result.
  225.    */
  226.  
  227.   NS_IMETHOD IsDone(PRBool *aIsDone) = 0;
  228.  
  229.   /**
  230.    * SetSelection() allows the caller to set the selection
  231.    * based on an offset into the string returned by
  232.    * GetCurrentTextBlock(). A length of zero places the cursor
  233.    * at that offset. A positive non-zero length "n" selects
  234.    * n characters in the string.
  235.    * @param aOffset offset into string returned by GetCurrentTextBlock().
  236.    * @param aLength number characters selected.
  237.    */
  238.  
  239.   NS_IMETHOD SetSelection(PRInt32 aOffset, PRInt32 aLength) = 0;
  240.  
  241.   /**
  242.    * Scrolls the document so that the current selection is visible.
  243.    */
  244.  
  245.   NS_IMETHOD ScrollSelectionIntoView() = 0;
  246.  
  247.   /**
  248.    * Deletes the text selected by SetSelection(). Calling
  249.    * DeleteSelection with nothing selected, or with a collapsed
  250.    * selection (cursor) does nothing and returns NS_OK.
  251.    */
  252.  
  253.   NS_IMETHOD DeleteSelection() = 0;
  254.  
  255.   /**
  256.    * Inserts the given text at the current cursor position.
  257.    * If there is a selection, it will be deleted before the
  258.    * text is inserted.
  259.    */
  260.  
  261.   NS_IMETHOD InsertText(const nsString *aText) = 0;
  262.  
  263.   /**
  264.    * Sets the display style for the text selected by SetSelection().
  265.    * @param aStyle is the style to apply to the selected text.
  266.    */
  267.  
  268.   NS_IMETHOD SetDisplayStyle(TSDDisplayStyle aStyle) = 0;
  269.  
  270.   /**
  271.    * Returns the DOM range for a given offset and length
  272.    * @param aOffset offset into string returned by GetCurrentTextBlock().
  273.    * @param aLength number characters selected.
  274.    * @return aDOMRange the DOM range that represents the offset and length
  275.    */
  276.   NS_IMETHOD GetDOMRangeFor(PRInt32 aOffset, PRInt32 aLength, nsIDOMRange** aRange) = 0;
  277. };
  278.  
  279. #endif // nsITextServicesDocument_h__
  280.  
  281.